namespace ACRSAP.Issues.UserControls
{
    using ASPNET.StarterKit.IssueTracker.UserInterfaceLayer;
    using Microsoft.VisualBasic.CompilerServices;
    using System;
    using System.Collections;
    using System.Diagnostics;
    using System.Runtime.CompilerServices;
    using System.Web.UI;
    using System.Web.UI.WebControls;

    public class IssueTabs : UserControl
    {
        private int _IssueId;
        [AccessedThroughProperty("lstTabs")]
        private DataList _lstTabs;
        [AccessedThroughProperty("plhContent")]
        private PlaceHolder _plhContent;
        private Control contentControl;
        private object designerPlaceholderDeclaration;

        public IssueTabs()
        {
            base.Load += new EventHandler(this.Page_Load);
            base.Init += new EventHandler(this.Page_Init);
            base.PreRender += new EventHandler(this.Page_PreRender);
            this._IssueId = 0;
        }

        [DebuggerStepThrough]
        private void InitializeComponent()
        {
        }

        public void LoadTab()
        {
            string controlName = "Comments.ascx";
            switch (this.lstTabs.SelectedIndex)
            {
                case 0:
                    controlName = "Comments.ascx";
                    break;

                case 1:
                    controlName = "Attachments.ascx";
                    break;

                case 2:
                    controlName = "History.ascx";
                    break;

                case 3:
                    controlName = "Notifications.ascx";
                    break;

                case 4:
                    controlName = "SubIssues.ascx";
                    break;

                case 5:
                    controlName = "ParentIssues.ascx";
                    break;

                case 6:
                    controlName = "RelatedIssues.ascx";
                    break;
            }
            this.contentControl = this.Page.LoadControl("~/Issues/UserControls/" + controlName);
            ((IIssueTab) this.contentControl).IssueId = this._IssueId;
            this.plhContent.Controls.Clear();
            this.plhContent.Controls.Add(this.contentControl);
            this.contentControl.ID = "ctlContent";
        }

        public void lstTabs_ItemCommand(object s, DataListCommandEventArgs e)
        {
            this.lstTabs.SelectedIndex = e.Item.ItemIndex;
            this.LoadTab();
            ((IIssueTab) this.contentControl).Initialize();
        }

        public void lstTabs_ItemDataBound(object s, DataListItemEventArgs e)
        {
            LinkButton lnkTab = (LinkButton) e.Item.FindControl("lnkTab");
            lnkTab.Text = StringType.FromObject(e.Item.DataItem);
        }

        private void Page_Init(object sender, EventArgs e)
        {
            this.InitializeComponent();
        }

        private void Page_Load(object sender, EventArgs e)
        {
            if (!this.Page.IsPostBack)
            {
                ArrayList colTabs = new ArrayList();
                colTabs.Add("客户备注");
                colTabs.Add("电子文档");
                colTabs.Add("修改记录");
                colTabs.Add("邮件提示");
                colTabs.Add("子公司");
                colTabs.Add("母公司");
                colTabs.Add("关联公司");
                this.lstTabs.DataSource = colTabs;
                this.lstTabs.SelectedIndex = 0;
                this.lstTabs.DataBind();
            }
            this.LoadTab();
        }

        private void Page_PreRender(object sender, EventArgs e)
        {
            if (!this.Page.IsPostBack)
            {
                ((IIssueTab) this.contentControl).Initialize();
            }
        }

        public int IssueId
        {
            get
            {
                return this._IssueId;
            }
            set
            {
                this._IssueId = value;
            }
        }

        protected virtual DataList lstTabs
        {
            get
            {
                return this._lstTabs;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                if (this._lstTabs != null)
                {
                    this._lstTabs.ItemDataBound -= new DataListItemEventHandler(this.lstTabs_ItemDataBound);
                    this._lstTabs.ItemCommand -= new DataListCommandEventHandler(this.lstTabs_ItemCommand);
                }
                this._lstTabs = value;
                if (this._lstTabs != null)
                {
                    this._lstTabs.ItemDataBound += new DataListItemEventHandler(this.lstTabs_ItemDataBound);
                    this._lstTabs.ItemCommand += new DataListCommandEventHandler(this.lstTabs_ItemCommand);
                }
            }
        }

        protected virtual PlaceHolder plhContent
        {
            get
            {
                return this._plhContent;
            }
            [MethodImpl(MethodImplOptions.Synchronized)]
            set
            {
                if (this._plhContent != null)
                {
                }
                this._plhContent = value;
                if (this._plhContent != null)
                {
                }
            }
        }
    }
}

